% view_bananas.m - view an afni acpc mri
%

function view_bananas(vol, thresh)

% fprintf('\nImaging ....');
% fprintf('\nEstimated Time: 0.6 minutes\n');
tic;
% Replacing mask and vol RAI coords into coords displayed as RAI coords on
% rendered image. quirky matlab imaging thing.
vol = permute(vol,[2 1 3]);

Ds = smooth3(vol); % smoothing the volume for a clearer display. vol is frequently the vol_mask input so not smoothed
%[x,y,z,Ds] = reducevolume(vol,[2,2,2]);
clear data x y z vol;

hiso = patch(isosurface(Ds,thresh),...
    'FaceColor','green',...
    'EdgeColor','none');
% reducepatch(hiso,0.99);

view(-45,30) 
daspect([1,1,1])

lightangle(-60,30); 
%camlight(-60,30); 
lightangle(+60,30);
lightangle(+180,30);

set(gcf,'Renderer','zbuffer'); lighting phong
%set(hcap,'AmbientStrength',0.6); 
% isonormals(Ds,hiso)
set(hiso,'SpecularColorReflectance',0,'SpecularExponent',50,'SpecularStrength',0.25,'AmbientStrength',0.1)
rotate3d on;
xlabel('X');ylabel('Y');zlabel('Z');
xlim([1 191]);ylim([1 236]);zlim([1 171]);
axis equal
axis vis3d
% title(['Threshold = ',num2str(thresh),'']); %  Order is RAI. Right side of face has pos numbers. Matlab display problem']);
% fprintf('Actual Time: %-2.1f minutes\n', toc/60);
clear Ds;
